import request from '@/utils/request'

// 查询实有人口统计列表
export function listPopulation(query) {
  return request({
    url: '/community/community/list',
    method: 'get',
    params: query
  })
}

// 查询实有人口统计详细
export function getPopulation(id) {
  return request({
    url: '/community/community/' + id,
    method: 'get'
  })
}

// 新增实有人口统计
export function addPopulation(data) {
  return request({
    url: '/community/community',
    method: 'post',
    data: data
  })
}

/**
 * 啥都会v飞回电话
 * @param data
 * @returns {*}
 */
// 修改实有人口统计
export function updatePopulation(data) {
  return request({
    url: '/community/community',
    method: 'put',
    data: data
  })
}

// 删除实有人口统计
export function delPopulation(id) {
  return request({
    url: '/community/community/' + id,
    method: 'delete'
  })
}

export function handleimport(file) {
  const formData = new FormData();
  formData.append('file', file); // 将文件添加到 FormData 对象中

  return request({
    url: '/community/community/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data' // 设置正确的 Content-Type
    }
  });
}


export function getlistPopulation() {
  return request({
    url: '/community/community/populationList',
    method: 'get'
  })
}

export function getPopulationType() {
  return request({
    url: '/community/community/populationType',
    method: 'get'
  })
}

export function getLabelList() {
  return request({
    url: '/community/community/labelList',
    method: 'get'
  })
}

export function handleClick(data) {
  return request({
    url: '/community/community/handleEmigration',
    method: 'post',
    data: data
  })
}
export function selectEmigrationLog(id) {
  return request({
    url: '/community/community/EmigrationLog',
    method: 'post',
    params:{id}
  })
}

export function listRidgepole(id) {
  return request({
    url: '/community/community/listRidgepole',
    method: 'post',
    params:{id}
  })
}
export function getElementList(id,did) {
  return request({
    url: '/community/community/getElementList',
    method: 'post',
    params:{id,did}
  })
}
export function getHouseholdsList(element,ridgepole,did) {
  return request({
    url: '/community/community/getHouseholdsList',
    method: 'post',
    params:{element, ridgepole, did}
  })
}

/**
 * 查询当前小区下的实有人口
 */
export function selPopulation(districtId) {
  return request({
    url: '/community/community/selPopulation?districtId='+districtId,
    method: 'get'
  })
}
